package com.action;

import com.pojo.Area;
import com.service.AreaService;
import com.vo.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")

public class AreaAction {

    @Autowired
    private AreaService areaService;

    /**
     * 根据已选城市查询所有县区
     * @param cityCode 城市code
     * @return
     */
    @RequestMapping("/findArea")
    public ResponseBean findArea(String cityCode){
        List<Area> list = areaService.findArea(cityCode);
        if (list != null){
            return new ResponseBean(200,0,list);
        }
        return new ResponseBean(500,0,"查询失败");
    }
}
